Passed
Push — feature/improve-applicant-list ( 332444...99a6ae )
by Chris
04:37 queued 15s
created

ApplicationReviewWithNav.render   C

Complexity

Conditions 5

Size

Total Lines 218
Code Lines 185

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 185
c 0
b 0
f 0
dl 0
loc 218
rs 6.5333
cc 5

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
import React from "react";
2
import { FormattedMessage, useIntl } from "react-intl";
3
import { Application, ApplicationReview } from "../../models/types";
4
import { Portal } from "../../models/app";
5
import ApplicationRow from "./ApplicationRow";
6
import {
7
  hrJobPreview,
8
  managerJobPreview,
9
  hrJobApplications,
10
  managerJobApplications,
11
} from "../../helpers/routes";
12
13
interface ApplicationReviewWithNavProps {
14
  application: Application;
15
  handleUpdateApplicationReview: (review: ApplicationReview) => Promise<void>;
16
  portal: Portal;
17
}
18
19
const ApplicationReviewWithNav: React.FC<ApplicationReviewWithNavProps> = ({
20
  application,
21
  handleUpdateApplicationReview,
22
  portal,
23
}): React.ReactElement => {
24
  const intl = useIntl();
25
26
  const jobUrlMap: { [key in typeof portal]: string } = {
27
    hr: hrJobPreview(intl.locale, application.job_poster_id),
28
    manager: managerJobPreview(intl.locale, application.job_poster_id),
29
  };
30
31
  const jobApplicationsUrlMap: { [key in typeof portal]: string } = {
32
    hr: hrJobApplications(intl.locale, application.job_poster_id),
33
    manager: managerJobApplications(intl.locale, application.job_poster_id),
34
  };
35
36
  const jobUrl = jobUrlMap[portal];
37
  const jobApplicationsUrl = jobApplicationsUrlMap[portal];
38
39
  return (
40
    <div>
41
      <div>
42
        <div className="manager-application-preview-actions flex-grid">
43
          <div className="box small-1of3">
44
            <button
45
              className="button--blue light-bg"
46
              type="button"
47
              onClick={() => {
48
                window.location.href = jobApplicationsUrl;
49
              }}
50
            >
51
              {`< `}
52
              <FormattedMessage
53
                id="application.review.backToApplicantList"
54
                defaultMessage="Save and Go Back to Applicant List"
55
                description="Back Button text"
56
              />
57
            </button>
58
          </div>
59
          <div className="box small-2of3">
60
            <a
61
              className="button--blue light-bg"
62
              href={jobUrl}
63
              style={{ marginRight: ".5rem" }}
64
            >
65
              <FormattedMessage
66
                id="application.review.button.viewJobPoster"
67
                defaultMessage="View Job Poster"
68
                description="View Job Poster Button text"
69
              />
70
            </a>
71
            <button
72
              className="button--blue light-bg"
73
              data-button-type="expand-all"
74
              type="button"
75
              id="expand-all"
76
            >
77
              <span className="expand">
78
                {" "}
79
                <FormattedMessage
80
                  id="application.review.expandAllSkills"
81
                  defaultMessage="Expand All Skills"
82
                  description="Expand All Skills Button text"
83
                />
84
              </span>
85
              <span className="collapse">
86
                {" "}
87
                <FormattedMessage
88
                  id="application.review.collapseAllSkills"
89
                  defaultMessage="Collapse All Skills"
90
                  description="Collapse All Skills Button text"
91
                />
92
              </span>
93
            </button>
94
          </div>
95
        </div>
96
      </div>
97
      <ApplicationRow
98
        application={application}
99
        handleUpdateReview={handleUpdateApplicationReview}
100
        portal={portal}
101
      />
102
    </div>
103
  );
104
};
105
106
export default ApplicationReviewWithNav;
107